﻿using System;
using System.Windows.Forms;

namespace msnet_2
{
    public partial class CalcForm : Form
    {
        public CalcForm()
        {
            InitializeComponent();
            MethodCombo.SelectedIndex = 0;
            Number1.Maximum = decimal.MaxValue;
            Number1.Minimum = decimal.MinValue;
            Number2.Maximum = decimal.MaxValue;
            Number2.Minimum = decimal.MinValue;
        }

        private void CalculateBtn_Click(object sender, EventArgs e)
        {
            decimal result = 0;
            switch (MethodCombo.SelectedIndex)
            {
                case 0: result = Number1.Value + Number2.Value; break;
                case 1: result = Number1.Value - Number2.Value; break;
                case 2: result = Number1.Value * Number2.Value; break;
                case 3:
                    if (Number2.Value == 0)
                    {
                        MessageBox.Show("被除数不能为0！");
                        return;
                    }
                    result = Number1.Value / Number2.Value;
                    break;
            }
            ResultBox.Text = result.ToString();
        }
    }
}
